<% 
function getlevelstr(Ulevel)
	set rs = conn.execute("select UlevelName from Userlevel where Ulevel="&Ulevel)
	if not rs.eof then
		getlevelstr=rs(0)	
	else
		getlevelstr="无"
	end if
end function

'**************************************************
'读取静态页面
'GetContent(SortId)
'**************************************************
function GetContent(SortId)
	sql="select Content from t_News_Class where ClassID="&SortId
	set rsT = conn.execute(sql)	
	GetContent=rsT(0)
	rsT.close
	set rsT = nothing	
end function
'**************************************************
'读取静态页面的名称
'GetLName(SortId)
'**************************************************
function GetLName(SortId)
	sql="select ClassName from t_News_Class where ClassID="&SortId
	set rs = conn.execute(sql)	
	GetLName=rs(0)
	rs.close
	set rs = nothing	
end function

'**************************************************
'得到静态页面的第一条记录的ID
'GetPSortID(parentID)
'**************************************************
function GetPSortID(parentID)
	sql="select top 1 ClassID from t_News_Class where ParentID="&parentID&" order by OrderID"
	set rs = conn.execute(sql)	
	GetPSortID=rs(0)
	rs.close
	set rs = nothing	
end function

'**************************************************
'判断Sortid是否存在
'IsExis(SortId)
'**************************************************
function IsExis(sql,SortId)
	if SortId<>"" and isnumeric(SortId) then
		set rs = conn.execute(sql)	
		if rs.eof then
			IsExis=2
			'PrintErrMsg("参数错误","")
		else
			IsExis=1
		end if
		rs.close
		set rs = nothing
	else
		IsExis=0
	end if
end function

'*******************
'去除字符串的最后一个"'"
'GetStr(str)
'*******************
function GetStr(str)
	if str<>"" then
		if right(str,1)="," then
			GetStr=left(str,len(str)-1)
		else
			GetStr=str
		end if
	else
		GetStr=str
	end if
end function

'**************************************************
'读取新闻类的名称
'GetNName(SortId)
'**************************************************
function GetNName(SortId)
	sql="select Newsort from t_brand_sort where ID="&SortId
	set rs = conn.execute(sql)	
	GetNName=rs(0)
	rs.close
	set rs = nothing
end function

'**************************************************
'读取产品类的名称
'GetNName(SortId)
'**************************************************
function GetPName(SortId,ver,IsBC)
	if SortId<>0 then
		if IsBC=1 then
			sql="select dalei from dalei where catalogID="&SortId
		else
			sql="select TypeName from t_productii_type where id="&SortId
		end if
		set rs = conn.execute(sql)	
		if not rs.eof then
			GetPName=rs(0)
		end if
		rs.close
		set rs = nothing
	else
		if ver="cn" then
			GetPName="所有商品"
		else
			GetPName="Products"
		end if
	end if
end function

'**************************************************
'读取下载类的名称
'GetDName(SortId)
'**************************************************
function GetDName(SortId,ver)
	if SortId<>0 then
		sql="select dalei from dalei where catalogID="&SortId
		set rs = conn.execute(sql)	
		GetDName=rs(0)
		rs.close
		set rs = nothing
	else
		if ver="cn" then
			GetDName="下载中心"	
		else
			GetDName="DownLoad"
		end if
	end if
end function
'**************************************************
'格式化日期
'FormatDate(NDate)
'**************************************************
function FormatDate(NDate)
	MM=Month(NDate)
	DD=Day(NDate)
	IF MM<10 then
		MM="0"&Cstr(MM)
	end if
	IF DD<10 then
		DD="0"&Cstr(DD)
	end if
	FormatDate=Year(NDate)&"."&MM&"."&DD
end function

'**************************************************
'打印错误信息
'PrintErrMsg(ErrMsg,RUrl)
'**************************************************
function PrintErrMsg(ErrMsg,RUrl)
	if RUrl="" then
		response.Write("<script language='Javascript'>alert('"&ErrMsg&"');history.go(-1);</script>")
	else
		response.Write("<script language='Javascript'>alert('"&ErrMsg&"');location='"&RUrl&"';</script>")
	end if
	response.End()
end function

'**************************************************
'格式化从编辑器中读出的字符串
'HTMLEncode(fString)
'**************************************************
function HTMLEncode(fString)
if not isnull(fString) then
'    fString = replace(fString, ">", "&gt;")
'    fString = replace(fString, "<", "&lt;")
	fString = Replace(fString, CHR(32), "&nbsp;")
	fString = Replace(fString, CHR(34), "&quot;")
	fString = Replace(fString, CHR(39), "&#39;")
	fString = Replace(fString, CHR(13), "")
	fString = Replace(fString, CHR(10) & CHR(10), "</P><P> ")
	fString = Replace(fString, CHR(10), " ")
	HTMLEncode = fString
end if
end function
'**************************************************
'格式Email,用*替换原字母
'changeEmail(Email)
'**************************************************
function changeEmail(Email)
	if Email<>"" then
		p=InStr(Email,"@")
		if p<>0 then
			length=len(Email)
			lStr=left(Email,p-1)
			Sstr=""
			for j=1 to p-1
				Sstr=Sstr&"*"
			next
			r=right(Email,length-p)
			changeEmail=Sstr&"@"&r
		else
			changeEmail=Email
		end if
	else
		changeEmail=Email
	end if
end function

Function RndNumber(MaxNum,MinNum)
Randomize 
RndNumber=int((MaxNum-MinNum+1)*rnd+MinNum)
RndNumber=RndNumber
End Function

'创建用户NO
function CreateUserNO(TempID)
	tempData=1234
	TempCounts=100000000+1234+TempID
	TempNO="G"&Cstr(TempCounts)	
	CreateUserNO=TempNO
end function

function MailSend(sendEmail,subject,content)
	'发邮件通知开始	
	Set jmail = Server.CreateObject("JMAIL.Message")    '建立发送邮件的对象
	jmail.silent = true   								'屏蔽例外错误,返回FALSE跟TRUE两值j
	jmail.logging = true   								'启用邮件日志
	jmail.Charset = "gb2312"     						'邮件的文字编码为国标
	jmail.ContentType = "text/html"    					'邮件的格式为HTML格式
	jmail.AddRecipient sendEmail   						'邮件收件人的地址
	jmail.From = "send@1000v.cn"  					'发件人的E-MAIL地址
	jmail.MailServerUserName = "send@1000v.cn"     	'登录邮件服务器所需的用户名
	jmail.MailServerPassword = "1000vcn"    				'登录邮件服务器所需的密码
	jmail.Subject = subject
	jmail.Body = content   								'邮件的内容
	'jmail.Prority = 1     								'邮件的紧急程序,1 为最快,5 为最慢, 3 为默认值
	jmail.Send("mail.1000v.cn")    						'执行邮件发送（通过邮件服务器地址）
	jmail.Close() 
	'发邮件通知结束 
end function

'getLevelName()
function getLevelName(tempNO)
	if tempNO<>"" then
		sql="select * from MemberLevel where ID="&tempNO
		set rs_temp=conn.execute(sql)
		if not rs_temp.eof then
			TempStr=rs_temp("Mlevel")
		else
			TempStr=""
		end if
		rs_temp.close
		set rs_temp = nothing
	else
		TempStr=""
	end if
	getLevelName=TempStr
end function

'得到产品的名称
function GetProName(TempID)
	if TempID<>"" then
		sql="select Pname from t_productii where ID="&TempID
		set rs_temp=conn.execute(sql)
		if not rs_temp.eof then
			TempStr=rs_temp(0)
		else
			TempStr=""
		end if
		rs_temp.close
		set rs_temp = nothing
	else
		TempStr=""
	end if
	GetProName=TempStr
end function

'得到特惠所要求的金额
function GetPromotionPrice()
	sql="select price from t_News_Class where ClassID=5"
	set rs_temp=conn.execute(sql)
	if not rs_temp.eof then
		TempStr=rs_temp(0)
	else
		TempStr=""
	end if
	GetPromotionPrice=TempStr
end function
'生成优惠代码
function GetYHCode(TempDate)
	'先格式化一下TempDate
	if TempDate<>"" then
		'response.Write(TempDate&"shiyi")
		TempVal=right(TempDate,len(TempDate)-1)
		TempArr=split(TempVal,"-")
		if TempArr(0)<10 then 
			MM="0"&TempArr(0)
		else
			MM=TempArr(0)
		end if
		if TempArr(1)<10 then 
			DD="0"&TempArr(1)
		else
			DD=TempArr(1)
		end if
		TempDate=MM&DD
		sql="select top 1 ID from YHCode order by id desc"
		set TempRs=conn.execute(sql)
		if not TempRs.eof then
			GetYHCode="Rain99"&TempDate&getNo(TempRs(0)+1)
		else
			GetYHCode=""
		end if
		TempRs.close
		set TempRs = nothing
	end if
end function

function getNo(i)
	if i<10 then
		getNo="0000"&Cstr(i)
	elseif i<100 then
		getNo="000"&Cstr(i)
	elseif i<1000 then
		getNo="00"&Cstr(i)
	elseif i<10000 then
		getNo="0"&Cstr(i)
	else
		getNo=Cstr(i)
	end if
end function

function InsertYHCode(T_BirthdayNo,T_Price,T_UserEmail)
	sql="Insert into YHCode(BirthdayNo,Price,UserEmail) values('"&T_BirthdayNo&"',"&T_Price&",'"&T_UserEmail&"')"
	conn.execute(sql)
end function

''传入一sql串求和
'function getSumValue(SqlStr)	
'	set TempRS=conn.execute(SqlStr)
'	do while not TempRS.eof
'		TempSum=TempRS(0)
'		TempRS.movenext
'	loop
'end function
'传入一个sql语句return一个字段的值
'GetFieldValue(TempSql)
function GetFieldValue(TempSql)
'response.Write TempSql
	set TempRs = conn.execute(TempSql)
	if not TempRs.eof then
		if TempRs(0)<>"" then
			GetFieldValue=TempRs(0)
		end if
	end if
	TempRs.close
	set TempRs = nothing
end function

function getTag(tagStr)
	if tagStr<>"" and tagStr<>null then
		lngSubKey = 2
		lngLenKey=0
		strNew1 = ""
		strNew2 = ""
		strSubKey = ""
		lngLenKey = Len(tagStr)
		select case lngLenKey
			case 1:
				strNew1 = ""
				strNew2 = ""
			case else
				array tagArr = Split(tagStr," ")
				for i=0 to Ubound(tagArr)
					if i=0 then
						if tapArr(i)<>"" then
							strNew1=strNew1&" PName like '%"&tapArr(i)&"%'"
						end if
					else
						strNew1=strNew1&" or PName like '%"&tapArr(i)&"%'"
					end if
				next
		end select
	end if
	getTag=strNew1
end function

function getDate()
	getDate=FormatDateTime(now,1)&" "&WeekdayName(Weekday(now))
end function

function clearSpecial(strT)
	if strT<>"" then
		strT=replace(strT,"'","")
		strT=replace(strT," or ","")
	end if
	clearSpecial=strT
end function 

function getP_Member(p_our)
	getP_Member=int(p_our*0.95)
end function

function getP_Vip(p_our)
	getP_Vip=int(p_our*0.95)-3
end function

function CreateOrderNo()
	CreateOrderNo=replace(right(year(now),2)&month(now)&day(now)&hour(now)&minute(now)&second(now)&right(timer(),2),".","0")
end function

'***********************************************************'
'* 函数名		: 反回ASP包函文件格式
'* 传递参数		: FilePath	所包函文件的路径
'* 日	期		: 2006-1-23
'***********************************************************'
Function IncludeFile(FilePath)
	Dim TempStr
	TempStr = "<!--#"
	TempStr = TempStr&"include file="""
	TempStr = TempStr&FilePath
	TempStr = TempStr&"""-->"
	IncludeFile = TempStr
End Function

'****************************************
'格式化序号
'****************************************
function FormatSerialNo(tNO,tC)
	tNOl=len(tNO)
	if tNOl<tc then		
		for t=1 to tc-tNOl
			tNO="0"&tNO
		next
	end if
	FormatSerialNo=tNO
end function

'*******************
'格式化字符串"'"
'formatStr(str,expression,Slen)
'expression为要去掉的字符串
'Slen为要去掉的字符串的长度
'*******************
function formatStr(TStr,expression,Slen)
	TStr=trim(TStr)
	if TStr<>"" then
		if right(TStr,Slen)=expression then
			TempStr_F=left(TStr,len(TStr)-Slen)
		else
			TempStr_F=TStr
		end if
	else
		TempStr_F=TStr
	end if
	formatStr=TempStr_F
end function

function CreateProductSelect()
	strT="<select name=""product"" onchange=""MM_jumpMenu('parent',this,0)"">"
	strT=strT&"<option>All Products</option>"
	sql="select ID,Title from Products where TypeId=2 order by Title,ID"
	set rs = conn.execute(sql)
	do while not rs.eof
		strT=strT&"<option value=""product.asp?pid="&rs("ID")&""">"&rs("Title")&"</option>"
		rs.movenext
	loop
	strT=strT&"</select>"
	response.Write(strT)
end function

function GetSIM(SIM)
	strT=""
	select SIM
		case 
	response.Write(strT)
end function
%>